package com.book.util;

import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.IContext;
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;

import java.io.Writer;

/*
 **@Author:youpeng
 **Created on 2022/4/24
 */
public class ThymeleafUtil {
    private static final TemplateEngine engine;
    static {
        engine=new TemplateEngine();
        ClassLoaderTemplateResolver r = new ClassLoaderTemplateResolver();
        r.setPrefix("/template/");
        r.setCharacterEncoding("UTF-8");
        engine.setTemplateResolver(r);
    }
    public static void process(String template, IContext context, Writer writer){
        engine.process(template,context,writer);
    }

}
